package com.power.using.mybomb.adapter;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.power.using.mybomb.R;
import com.power.using.mybomb.base.ImageLoaderFactory;
import com.power.using.mybomb.bean.User;
import com.power.using.mybomb.ui.UserInfoActivity;

import butterknife.BindView;

/**
 * Created by 聪明一只哈 on 2020/3/23.
 * Time: 2020/3/23  14:42
 */
public class SearchUserHolder extends BaseViewHolder {


    @BindView(R.id.avatar)
    ImageView avatar;
    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.btn_add)
    Button btnAdd;

    public SearchUserHolder(Context context, ViewGroup root,  OnRecyclerViewListener listener) {
        super(context, root, R.layout.item_search_user, listener);
    }

    @Override
    public void bindData(Object o) {
        User user= (User) o;
        ImageLoaderFactory.getLoader().loadAvator(avatar,user.getAvatar(),R.mipmap.head);
        name.setText(user.getUsername());
        btnAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Bundle bundle = new Bundle();
                bundle.putSerializable("u",user);
                startActivity(UserInfoActivity.class,bundle);
            }
        });


    }
}
